/*
 *	Build scene with canvas
 */
define(function() {
	var Scene = function(SceneConf) {
		// Initialize scene according to configuration
		for(property in SceneConf) {
			this[property] = SceneConf[property];
		}

		// Set ratio for the display
		var ratio = 1;

		//debug - simulate iPhone
		AppMobi.isnative = true;
		AppMobi.isphone = true;

		if(AppMobi.isnative === true) {
			if(AppMobi.isphone === true && AppMobi.device.platform === "iOS") {
				alert("Set ratio for iPhone");
				ratio = 1.5;
			} else if(AppMobi.istablet === true && AppMobi.device.platform === "iOS") {
				alert("Set ratio for iPad");
				ratio = 1.85;
			} else if(AppMobi.device.platform === "Android") {
				alert("Set ratio for Android");
				ratio = 1.75;
			}
		}

		this.width = (this.orientation === "landscape") ? this.size * ratio : this.size;
		this.height = (this.orientation === "portrait") ? this.size * ratio : this.size;
		
		// Create Canvas
		this.canvas = document.createElement('canvas');
		// Configure it
		this.canvas.id = SceneConf.id;
		this.canvas.width = this.width;
		this.canvas.height = this.height;

		// Add it to page
		var body = document.getElementsByTagName("body")[0];
		body.appendChild(this.canvas);

		// Get context for canvas
		this.ctx = this.canvas.getContext('2d');

		this.setViewPort = function() {
			//lock orientation
	        AppMobi.device.setRotateOrientation(this.orientation);
	        AppMobi.device.setAutoRotate(false);
		    //Size the display to conf size
		    AppMobi.display.useViewport(this.width,this.height);
		}
	}

	return Scene;
});